﻿/*
   Author: Tomer Paz
   games.com
   2007
*/
// the game Commands interface class
// defines the network commands Sent and Recieved to/from game server
// the interface structure is actually describing a Flow of client/server session

package monopoly.CMD {
	
	import flash.events.IEventDispatcher;
	import flash.utils.ByteArray;
	import monopoly.CMD.CMDResponse;

	public interface ICMD extends IEventDispatcher
		{
		function readSRVHLO(cmdRes:CMDResponse):void;	// cmd code 100
		function sendINTRO(clientVer:int, gameID:int):void;	// cmd code 120
		function readACCEPT(cmdRes:CMDResponse):void;	// cmd code 130
		function readSTATUS(cmdRes:CMDResponse):void;	// cmd code 140
		function ready(PlayerType:int):void;			// cmd code 160	- Sends(!) join/view request to server. 
		function sendStart():void;						// cmd code 170 - Sends "start game" to server 

		// server shall respond true/false for verifying client command received and accepted.
		// this command is executed in the "Are you ready?" dialog context.
		//function set_status(Status:Array):void;	// cmd code = 10 - fills referenced parmeters.
		//Returns Mode - wait X seconds or Move (0 for move, >0 how many seconds to wait)
		/* add chat system */
		function chat(message:String, player_id:uint, rcpt:uint):void;
		
		function set ClientID(clientid:uint):void;
		function set SessionID(sessionID:String):void;
		
		/* the game commands */
		
		function throw_dies():void;	// sends the throw dies request to server - 400
		function done_move(NewPosition:uint):void;	// client sends the desired move and expect server approval (allow/deny) - 420
		function ac_resign():void;			// client resign game - 998
		function CMDdisconnect():void;		// client disconnect session - 999

		/* property actions - each returns server Verification success/fail through the server STATUS report */

		function ac_none():void;												// action none - 430
		function ac_pay(Player:uint, PropertyID:uint, Sum:uint):void;			// action pay  - 440 - pay to owner
		function ac_buy(Player:uint, PropertyID:uint, Sum:uint):void;			// action buy  - 450
		function ac_sell(Player:uint, PropertyID:uint, Sum:uint):void;			// action sell - 460
		function ac_mortgage(Player:int, Properties:Array, Sum:int):void;		// action mortgage - 470
		function ac_upgrade(fieldID:int, upgrade_level:int):void;				// action upgrade - 480
		function end_turn():void;							// just inform server turn is over - retuns success/fail- 555
		function ac_req_buy(response:uint):void;								// in response to other player buy request
		function ac_req_exchange(response:uint):void;							// in response to other player exchange request
		function ac_req_partner(response:uint):void;							// in response to other player partner request
		function ac_req_sell(response:uint):void;								// in response to other player sell request
		function ac_auction(fieldID:int, sum:int):void;							// action auction - 490 or 690 (response)
		
		/* state machine helper functions */
		
		function get State():int;
		function set State(state:int):void;
		
		/* some other getters */
		
		function get Authorized():Boolean;		// return if server authorized this client
		
		// and just for the record - getInstance() for singleton implementation
		//function getInstance(HostName:String, Port:int):ICMD;
		function get SessionID():String;
		function get ServerName():uint;
		function get ServerVersion():uint;
		}
}